package com.hqyj.nacoscaller.controller;

import com.hqyj.nacoscommon.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {

    private final static String SERVER_URL = "http://localhost:8080";
    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/getUserName")
    public Map getUserName() {
        String url = SERVER_URL + "/user/getUserName";
        User user = restTemplate.getForObject(url , User.class);
        Map map = new HashMap();
        map.put("code" , 200);
        map.put("data" , user);
        map.put("type" , "caller");
        return map;
    }

}
